<html>
    <head>
        <title>DNSPOD TOOl</title>
        <script type="text/javascript" src="/static/js/global/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="/static/css/tools/action.css"></link>
        <script type="text/javascript">
        $(function() {
            $(".delNode").click(function() {
                var thisObj = $(this);
                var dnspodId = thisObj.attr("dnspodId");
                var project = $("[name=project]:checked").val();
                var environment = $("[name=environment]:checked").val();
                var domain_type = $("[name=domain_type]:checked").val();

                if (!project || !environment || !domain_type || environment == 'production') {
                    alert("环境配置有误");
                    return;
                }
                if (!dnspodId) {
                    alert("ID有误");
                    return;
                }

                var confirm = window.confirm("确定要删除，谨慎操作？");
                if (!confirm) {
                    return false;
                }

                $.post(
                    '/DnspodTool/deleteRecordAjax',
                    {dnspodId:dnspodId, project:project, environment:environment, domain_type:domain_type},
                    function(res) {
                        if (res && res.status.code == 1) {
                            thisObj.parent().parent().remove();
                            alert('删除成功');
                        } else {
                            alert(res.status.message ? res.status.message : "删除失败");
                        }
                    },'json'
                )
            })
        })
        </script>
        <style type="text/css">
            tr {
                border: 1px solid blue;
                font-size: 14px;
            }
            .tr_f1 {
                background: #98FB98;
            }
            .action a {
                color:red;
                font-size:12px;
            }
        </style>
    </head>

    <body>
        <h3>RECORD LISTS</h3>
        <form id = "myform" action="" method="post">
            <div>
                <span>项目：</span>
                <input name="project" <{if $search.project != 'fuse'}> checked="checked" <{/if}> value="self" type="radio">自建
                <input name="project" <{if $search.project == 'fuse'}>checked="checked" <{/if}>  value="fuse" type="radio">融合
            </div>
            <div>
                <span>环境：</span>
                <input name="environment" <{if $search.environment != 'production'}>checked="checked" <{/if}> value="development" type="radio">开发/测试
                <input name="environment" <{if $search.environment == 'production'}>checked="checked" <{/if}> value="production" type="radio">生产
            </div>
            <div>
                <span>域名：</span>
                <input name="domain_type" <{if $search.domain_type != 'outer'}>checked="checked" <{/if}> value="inner" type="radio">对内
                <input name="domain_type" <{if $search.domain_type == 'outer'}>checked="checked" <{/if}> value="outer" type="radio">对外
            </div>
            <div>
                <span>查询子域：</span>
                <input name="sub_domain" value="<{$search.sub_domain}>" type="text">
            </div>
            <div>
                <span>关键字：</span>
                <input name="keyword" value="<{$search.keyword}>" type="text">
            </div>
            <div>
                <span>查询数量：</span>
                <input name="length" value="<{if $search.length}><{$search.length}><{else}>10<{/if}>" type="text">
            </div>
            <div>
                <span>偏移起始：</span>
                <input name="offset" value="0" type="text">
            </div>
            <div id = 'submit'>
                <input type="submit" name="submit" value="筛选">
            </div>
        </form>


        <div>
            <span>主域：</span><{$domain.name}>(<{$domain.id}>)
            <span>子域：</span><{$info.sub_domains}>
            <span>记录总数：</span><{$info.record_total}>条
        </div>
        <br>
        <table >
            <tr class="tr_f1">
                <td>Num</td>
                <td>ID</td>
                <td>Sub_domain</td>
                <td>Line</td>
                <td>Type</td>
                <td>Record</td>
                <td>Ttl</td>
                <td>Status</td>
                <td>Monitor_status</td>
                <td>Update_time</td>
                <td>Action</td>
            </tr>
            <{foreach item = res key = key from=$records}>
            <tr <{if $key%2 == 0}> style="background:#EBEBEB;" <{/if}>>
                <td><{$key}></td>
                <td><{$res.id}></td>
                <td><{$res.name}></td>
                <td><{$res.line}></td>
                <td><{$res.type}></td>
                <td><{$res.value}></td>
                <td><{$res.ttl}></td>
                <td><{if $res.enabled == 1}>启用<{else}>暂停<{/if}></td>
                <td><{$res.monitor_status}> &nbsp;</td>
                <td><{$res.updated_on}></td>
                <td class="action">
                    <a class="delNode" dnspodId="<{$res.id}>" href="javascript:;">删除</a>
                </td>
            </tr>
            <{/foreach}>
        </table>
    </body>
</html>